import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/utils/cash_utils.dart';
import 'package:finance_app/src/widgets/wrapper/normal_form_wrapper.dart';
import 'package:flutter/material.dart';

class InventoryItemWidget extends StatelessWidget {
  final String time;
  final String name;
  final String status;
  final String unit;
  final int inventory;

  const InventoryItemWidget(
      {Key key, this.time, this.name, this.status, this.unit, this.inventory})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return NormalFormWrapper(
      topPadding: getDp(13),
      bottomPadding: getDp(14),
      leftPadding: getDp(35),
      rightPadding: getDp(35),
      hasBottomBorder: true,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                time,
                style: TextStyle(
                  color: aceBlackColor,
                  fontSize: getSp(14),
                  fontWeight: FontWeight.w400,
                  height: 1,
                ),
              ),
              SizedBox(
                height: getDp(7),
              ),
              Text(
                name,
                style: TextStyle(
                  color: aceBlackColor,
                  fontSize: getSp(16),
                  fontWeight: FontWeight.w700,
                  height: 16 / 14,
                ),
              ),
            ],
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Text(
                status,
                style: TextStyle(
                  color: getStatusColor(),
                  fontSize: getSp(14),
                  fontWeight: FontWeight.w400,
                  height: 1,
                ),
              ),
              SizedBox(
                height: getDp(7),
              ),
              Text(
                '${CashUtils.operation(inventory)} ${CashUtils.ignoreCashAmount(inventory)} $unit',
                style: TextStyle(
                  color: aceBlackColor,
                  fontSize: getSp(16),
                  fontWeight: FontWeight.w700,
                  height: 16 / 14,
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }

  Color getStatusColor() {
    switch (status) {
      case 'Adjusted':
        return aceDarkGrayColor;
      case 'Sold':
        return aceRedColor;
      case 'Purchased':
        return aceGreenColor;
    }
    return aceBlackColor;
  }
}
